<template>
    <div class="minishop-index ">
        <div class="top-panel">
            <img class="bg" src="/static/images/bg.png" alt="">
            <div class="content ">
                <div class="pl13">
                    <div class="search-area kitbox-mid">
                        <div><img src="/static/images/fdj.png" alt=""></div>
                        <div class="pl10 fs-13 c-1b1b1b">请输入内容查找</div>
                    </div>
                </div>
                <div class="list-wrap plr10">
                    <div class="list kitbox">
                        <div class="item">
                            <div><img class="photo" src="/static/images/kfyd.png" alt=""></div>
                            <div class="c-fff fs-13 pt6">客房预订</div>
                        </div>
                        <div class="item">
                            <div><img class="photo" src="/static/images/ywxm.png" alt=""></div>
                            <div class="c-fff fs-13 pt6">游玩项目</div>
                        </div>
                        <div class="item">
                            <div><img class="photo" src="/static/images/kfyd.png" alt=""></div>
                            <div class="c-fff fs-13 pt6">庄主推荐</div>
                        </div>           
                        <div class="item">
                            <div><img class="photo" src="/static/images/mysp.png" alt=""></div>
                            <div class="c-fff fs-13 pt6">名优商品</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="pro-list">
            <div class="kitbox-mid pt25 pb10 plr12 ">
                <div class="fs-18 c-000 flex1">名优商品</div>
                <div class="fs-16 c-696969">更多></div>
            </div>
            <div class="list plr5">
                <div v-for="i in 2" :key="i" class="item">
                    <div><img src="/static/images/wd-bg.png" alt=""></div>
                    <div class="fs-14 c-1b1b1b">古田水蜜桃</div>
                    <div class="kitbox-mid c-fb4957 fs-10 pt10 pr5">
                        <div class="flex1">￥<span class="fs-17">199</span><span class="ml5 c-a4a4a4">起</span></div>
                        <div class="c-a4a4a4">七天无理由</div>
                    </div>
                </div>
            </div>

            <div class="adv plr9 pt10">
                <img src="/static/images/wd-bg.png" alt="">
            </div>

            <div class="kitbox-mid pt45 pb10 plr12 ">
                <div class="fs-18 c-000 flex1">游玩项目</div>
                <div class="fs-16 c-696969">更多></div>
            </div>
            <div class="list plr5">
                <div v-for="i in 2" :key="i" class="item">
                    <div><img src="/static/images/wd-bg.png" alt=""></div>
                    <div class="fs-14 c-1b1b1b">古田水蜜桃</div>
                    <div class="kitbox-mid c-fb4957 fs-10 pt10 pr5">
                        <div class="flex1">￥<span class="fs-17">199</span><span class="ml5 c-a4a4a4">起</span></div>
                        <div class="c-a4a4a4">七天无理由</div>
                    </div>
                </div>
            </div>

            <div class="kitbox-mid pt45 pb10 plr12 ">
                <div class="fs-18 c-000 flex1">山水谈庄园 </div>
                <div class="fs-16 c-696969">更多></div>
            </div>
            <div class="list plr5">
                <div v-for="i in 2" :key="i" class="item">
                    <div><img src="/static/images/wd-bg.png" alt=""></div>
                    <div class="fs-14 c-1b1b1b">古田水蜜桃</div>
                    <div class="kitbox-mid c-fb4957 fs-10 pt10 pr5">
                        <div class="flex1">￥<span class="fs-17">199</span><span class="ml5 c-a4a4a4">起</span></div>
                        <div class="c-a4a4a4">七天无理由</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import tipApi from "@/api/api-tip";
import placeApi from "@/api/api-place";
import houseApi from "@/api/api-house";
import otherApi from '@/api/api-other'

import moment from '@/plugins/utils/moment.js'
export default {
    data () {
        var weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
        var week =  weekday[moment().weekday()]
        var next = moment().add(1, 'days'),  
            nextWeek =  weekday[next.weekday()]
        return {
            tipList: [],
            placeList: [],
            barnerList: [],
            houseList: [],
            indicatorDots: true,
            vertical: false,
            autoplay: true,
            interval: 3000,
            duration: 500,

            startMonth: moment().month() + 1,
            endMonth: next.month() + 1,
            startDayStr: moment().format('DD'),
            endDayStr: next.format('DD'),
            startDate: moment().format('YYYY-MM-DD'),
            endDate: next.format('YYYY-MM-DD'),
            startWeek: week,
            endWeek: nextWeek,
            days: 1,
            weekday
        }
    },
    watch: {
        '$store.getters.logined': {
            handler(n, o){
                if(n){
                    
                }
            }
        },
    },
    components: {
        
    },
    onLoad(options){
        wx.removeStorageSync("search-mslb")
    },
    mounted () {
        this.initPage()
    },
    onShow(){
        if(wx.getStorageSync("search-mslb") == 1){
            this.startDate = wx.getStorageSync("search-mslb-startDate") || ""
            this.endDate = wx.getStorageSync("search-mslb-endDate") || ""
            var m = moment(this.startDate),
                next = moment(this.endDate)
            this.startMonth = m.month() + 1;
            this.endMonth = next.month() + 1;
            this.startDayStr = m.format('DD');
            this.endDayStr = next.format('DD');
            this.startWeek = this.weekday[m.weekday()];
            this.endWeek = this.weekday[next.weekday()];
        }
        wx.removeStorageSync("search-mslb")
    },
    methods: {
        initPage(){
            this.ListTip()
            this.ListPlace()
            this.ListBanner()
            this.ListHouse()
        },
        ListTip(){
            tipApi.ListTip({
                pageIndex: 1,
                pageSize: 6
            }).then(data => {
                this.tipList = data.result.List || []
            })
        },
        ListPlace(){
            placeApi.ListPlace({
                pageIndex: 1,
                pageSize: 6
            }).then(data => {
                data.result.List.forEach(v => {
                    v.tags = (v.tag&&v.tag.split(" ")) || []
                })
                this.placeList = data.result.List || []
            })
        },
        ListHouse(){
            houseApi.ListHouse({
                pageIndex: 1,
                pageSize: 999
            }).then(data => {
                this.houseList = data.result.List || []
            })
        },
        ListBanner(){
            otherApi.ListBanner({
                adTypes: [1, 2]
            }).then(data => {
                // var barnerList = [];
                // (data.result||[]).forEach(v => {
                //     if(v.ad_type == 1){
                //         barnerList.push(v)
                //     } else if(v.ad_type == 4 && !this.advice){
                //         this.advice = v
                //     }
                // })
                
                this.barnerList = data.result
            })
        },
        
    },
    onShareAppMessage( options ){
        var that = this;
        // 设置菜单中的转发按钮触发转发事件时的转发内容
        var shareObj = {
            title: "",// 默认是小程序的名称(可以写slogan等)
            path: '/pages/index/index',// 默认是当前页面，必须是以‘/’开头的完整路径
            imageUrl: "",//自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
            success: function(res){
                // 转发成功之后的回调
                if(res.errMsg == 'shareAppMessage:ok'){
                    wx.showToast({
                        title: "分享成功",
                        icon: "success",
                        duration: 2000
                    })
                }
            },
            fail: function() {
                // 转发失败之后的回调
                if(res.errMsg == 'shareAppMessage:fail cancel'){
                    // 用户取消转发
                
                }else if(res.errMsg == 'shareAppMessage:fail'){
                    // 转发失败，其中 detail message 为详细失败信息
                    wx.showToast({
                        title: "分享失败",
                        icon: "success",
                        duration: 2000
                    })
                }
            },
            complete: function () {
                
            }
        };
        // 来自页面内的按钮的转发
        if( options.from == 'button' ){
            　
        }
        // 返回shareObj
        return shareObj;
    },
}
</script>

<style  lang="scss">
@import './scss/index.scss';
</style>
